<?php
include "config/koneksi.php";
$username = $_POST['username'];
$password = md5($_POST['password']);
if((!empty($username)) && (!empty($password))){
$query = mysql_query("SELECT * FROM com_user WHERE username = '$_POST[username]' and password='$password' ");
$data = mysql_fetch_array($query);
$cek = mysql_num_rows($query);
/* cek password dari database dengan yang dimasukkan ketika login, bila sama, maka login sukses dan muncul panel user */
if($cek > 0){
	session_start();	
	$_SESSION["user"] = $data["username"];
	$_SESSION["id_admin"] = $data["id_admin"];
	header("location:index.php");
	exit();
//jika kolom kosong
} else { 
echo "<center><h1>Mohon perhatian !</h1>";
echo "<p>Nama User atau Kata Sandi mohon dicek kembali. Silakan.. <a href='javascript:history.back();'> ULANGI</a> lagi jika ingi melanjutkan.</p></center>"; 
	}
}
else{
	echo "<script>alert('cek lagi ada yang salah..!');location.href='index.php'</script>";
	exit();
	}
?>